//
//  HomeModel.m
//  Topit
//
//  Created by dllo on 15/11/27.
//  Copyright © 2015年 YXY. All rights reserved.
//

#import "HomeModel.h"

@implementation HomeModel

-(void)dealloc {
    [_desc release];
    [_name release];
    [_ts release];
    [_next release];
    [_dataSource release];
    [super dealloc];
}


- (instancetype)initWithDataSource:(NSDictionary *)data
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:data];
    }
    return self;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if ([key isEqualToString:@"item"]) {
        NSArray *array = value;
        
        NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:0];
        for (NSDictionary *dic in array) {
            PictureModel *pictureModle = [[PictureModel alloc] initWithSource:dic];
            [mutableArray addObject:pictureModle];
            [pictureModle release];
        }
        self.dataSource = [[NSArray alloc] initWithArray:mutableArray];
    }
}

- (id)valueForUndefinedKey:(NSString *)key {
    return nil;
}

@end
